﻿using System;
using System.Collections.Generic;
using ProjScan.Tools;
using UnityEditor;

namespace ProjScan.Submodules.Shader_Analysis
{
	// Token: 0x02000181 RID: 385
	internal class ShaderOptimizationHandler
	{
		// Token: 0x06000D5E RID: 3422 RVA: 0x00006D47 File Offset: 0x00004F47
		public void ResetShaders()
		{
			Singleton<ShaderInfoManager>.Instance.Reset();
		}

		// Token: 0x06000D5F RID: 3423 RVA: 0x0003B784 File Offset: 0x00039984
		public static void OptimizeShaders()
		{
			ApiCompatibilityUtils.ProjScanShaderProcessorOn = true;
			Singleton<ShaderCompilationManager>.Instance.RegisterProcessShader();
			ShaderOptimizationHandler.I.ResetShaders();
			string[] scenesInBuild = ShaderOptimizationHandler.GetScenesInBuild();
			ApiCompatibilityUtils.Instance.UPS_BuildPlayer(scenesInBuild);
			ApiCompatibilityUtils.ProjScanShaderProcessorOn = false;
		}

		// Token: 0x06000D60 RID: 3424 RVA: 0x0003B7C8 File Offset: 0x000399C8
		private static string[] GetScenesInBuild()
		{
			EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
			HashSet<string> hashSet = new HashSet<string>();
			for (int i = 0; i < scenes.Length; i++)
			{
				bool flag = scenes[i].enabled && scenes[i].path.EndsWith(".unity");
				if (flag)
				{
					string path = scenes[i].path;
					bool flag2 = !hashSet.Contains(path);
					if (flag2)
					{
						hashSet.Add(path);
					}
				}
			}
			string[] array = new string[hashSet.Count];
			hashSet.CopyTo(array);
			return array;
		}

		// Token: 0x0400082C RID: 2092
		public static ShaderOptimizationHandler I = new ShaderOptimizationHandler();
	}
}
